#pragma once
#include <iostream>
#include <string>
#include <arpa/inet.h>
#include <netinet/in.h>
typedef struct sockaddr_in sockaddr_in;
class InetAddr
{
public:
    InetAddr(sockaddr_in addr)
        :_sockaddr(addr)
    {
        _port = ntohs(_sockaddr.sin_port);
        _ip = inet_ntoa(addr.sin_addr);
    }
    const std::string& Ip()
    {
        return _ip;
    }
    uint16_t Port()
    {
        return _port;
    }
    bool operator==(const InetAddr& addr)
    {
        return _ip == addr._ip && _port = addr._port;
    }
    ~InetAddr(){}
private:
    std::string _ip;
    u_int16_t _port;
    sockaddr_in _sockaddr;
};